package com.chao.auth.service;

import cn.hutool.core.collection.CollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * @author : Rookie
 * @description :
 * @date : 2022/4/11
 */
@Service
public class ResourceService {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @PostConstruct
    public void initData() {
        Map<String, String> resourceRolesMap = new TreeMap<>();
        resourceRolesMap.put("/resource/hello", "ADMIN");
        resourceRolesMap.put("/resource/userInfo", "ADMIN,USER");
        resourceRolesMap.put("/auth/currentUser", "ADMIN,USER");
        resourceRolesMap.put("/auth/checkScope", "ADMIN,USER");
        redisTemplate.opsForHash().putAll("AUTH:RESOURCE_ROLES_MAP", resourceRolesMap);
    }
}
